<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>删除记录</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.pg-dbname.html">pg_dbname</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.pg-end-copy.html">pg_end_copy</a></div>
 <div class="up"><a href="ref.pgsql.html">PostgreSQL 函数</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="function.pg-delete" class="refentry">
   <div class="refnamediv">
    <h1 class="refname">pg_delete</h1>
    <p class="verinfo">(PHP 4 &gt;= 4.3.0, PHP 5)</p><p class="refpurpose"><span class="refname">pg_delete</span> &mdash; <span class="dc-title">
     删除记录
    </span></p>

   </div>
 
 <div class="refsect1 description" id="refsect1-function.pg-delete-description">
  <h3 class="title">说明</h3>
    <div class="methodsynopsis dc-description">
     <span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> <span class="methodname"><strong>pg_delete</strong></span>
      ( <span class="methodparam"><span class="type">resource</span> <code class="parameter">$connection</code></span>
     , <span class="methodparam"><span class="type">string</span> <code class="parameter">$table_name</code></span>
     , <span class="methodparam"><span class="type">array</span> <code class="parameter">$assoc_array</code></span>
   [, <span class="methodparam"><span class="type">int</span> <code class="parameter">$options</code><span class="initializer"> = PGSQL_DML_EXEC</span></span>
    ] )</div>

    <p class="para rdfs-comment">
     <span class="function"><strong>pg_delete()</strong></span> 删除符合条件的记录，条件在 <em>assoc_array</em> 中以 <em>field=&gt;value</em> 格式给出。如果指定了 <em>option</em>，则 <span class="function"><a href="function.pg-convert.html" class="function">pg_convert()</a></span> 按照该选项作用于 <em>assoc_array</em> 之上。
    </p>
   </div>


<div class="refsect1 parameters" id="refsect1-function.pg-delete-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    
     <dt>
<em><code class="parameter">connection</code></em></dt>

     <dd>

      <p class="para">
       PostgreSQL database connection resource.
      </p>
     </dd>

    
    
     <dt>
<em><code class="parameter">table_name</code></em></dt>

     <dd>

      <p class="para">
       Name of the table from which to delete rows.
      </p>
     </dd>

    
    
     <dt>
<em><code class="parameter">assoc_array</code></em></dt>

     <dd>

      <p class="para">
       An <span class="type"><a href="language.types.array.html" class="type array">array</a></span> whose keys are field names in the table <em><code class="parameter">table_name</code></em>,
       and whose values are the values of those fields that are to be deleted.
      </p>
     </dd>

    
    
     <dt>
<em><code class="parameter">options</code></em></dt>

     <dd>

      <p class="para">
       Any number of <strong><code>PGSQL_CONV_FORCE_NULL</code></strong>, 
       <strong><code>PGSQL_DML_NO_CONV</code></strong>,
       <strong><code>PGSQL_DML_EXEC</code></strong> or
       <strong><code>PGSQL_DML_STRING</code></strong> combined. If <strong><code>PGSQL_DML_STRING</code></strong> is part of the
       <em><code class="parameter">options</code></em> then query string is returned.
      </p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.pg-delete-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   成功时返回 <strong><code>TRUE</code></strong>， 或者在失败时返回 <strong><code>FALSE</code></strong>。  Returns <span class="type"><a href="language.types.string.html" class="type string">string</a></span> if <strong><code>PGSQL_DML_STRING</code></strong> is passed
   via <em><code class="parameter">options</code></em>.
  </p>
 </div>

 
 <div class="refsect1 examples" id="refsect1-function.pg-delete-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-2024">
    <p><strong>Example #1 <span class="function"><strong>pg_delete()</strong></span> 例子</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php&nbsp;<br />&nbsp;&nbsp;$db&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">pg_connect</span><span style="color: #007700">(</span><span style="color: #DD0000">'dbname=foo'</span><span style="color: #007700">);<br />&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;This&nbsp;is&nbsp;safe,&nbsp;since&nbsp;$_POST&nbsp;is&nbsp;converted&nbsp;automatically<br />&nbsp;&nbsp;</span><span style="color: #0000BB">$res&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">pg_delete</span><span style="color: #007700">(</span><span style="color: #0000BB">$db</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'post_log'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$_POST</span><span style="color: #007700">);<br />&nbsp;&nbsp;if&nbsp;(</span><span style="color: #0000BB">$res</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"POST&nbsp;data&nbsp;is&nbsp;deleted:&nbsp;</span><span style="color: #0000BB">$res</span><span style="color: #DD0000">\n"</span><span style="color: #007700">;<br />&nbsp;&nbsp;}&nbsp;else&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"User&nbsp;must&nbsp;have&nbsp;sent&nbsp;wrong&nbsp;inputs\n"</span><span style="color: #007700">;<br />&nbsp;&nbsp;}<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

   </div>
  </p>
  <div class="warning"><strong class="warning">Warning</strong><p class="simpara">此函数是<em class="emphasis">实验性</em>的。此函数的表象，包括名称及其相关文档都可能在未来的
PHP 发布版本中未通知就被修改。使用本函数风险自担 。</p></div>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.pg-delete-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="function"><a href="function.pg-convert.html" class="function" rel="rdfs-seeAlso">pg_convert()</a> - 将关联的数组值转换为适合 SQL 语句的格式。</span></li>
   </ul>
  </p>
 </div>

  </div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.pg-dbname.html">pg_dbname</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.pg-end-copy.html">pg_end_copy</a></div>
 <div class="up"><a href="ref.pgsql.html">PostgreSQL 函数</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
